import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LawFirmVo, LawFirmForm, LawFirmQuery } from '@/api/lawfirm/lawfirm/types';

/**
 * 查询律所信息列表
 * @param query
 * @returns {*}
 */

export const listLawFirm = (query?: LawFirmQuery): AxiosPromise<LawFirmVo[]> => {
  return request({
    url: '/lawyer/lawFirm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询律所信息详细
 * @param lawFirmId
 */
export const getLawFirm = (lawFirmId: string | number): AxiosPromise<LawFirmVo> => {
  return request({
    url: '/lawyer/lawFirm/' + lawFirmId,
    method: 'get'
  });
};

/**
 * 新增律所信息
 * @param data
 */
export const addLawFirm = (data: LawFirmForm) => {
  return request({
    url: '/lawyer/lawFirm/saveLawFirm',
    method: 'post',
    data: data
  });
};

/**
 * 修改律所信息
 * @param data
 */
export const updateLawFirm = (data: LawFirmForm) => {
  return request({
    url: '/lawyer/lawFirm/updateLawFirm',
    method: 'post',
    data: data
  });
};

/**
 * 删除律所信息
 * @param lawFirmId
 */
export const delLawFirm = (lawFirmId: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/lawFirm/removeLawFirm/' + lawFirmId,
    method: 'delete'
  });
};

export const activeLawFirm = (lawFirmId: string | number) => {
  const data = {
    lawFirmId
  };
  return request({
    url: '/lawyer/lawFirm/activeLawFirm',
    method: 'post',
    data: data
  });
};

export const inactiveLawFirm = (lawFirmId: string | number) => {
  const data = {
    lawFirmId
  };
  return request({
    url: '/lawyer/lawFirm/inactiveLawFirm',
    method: 'post',
    data: data
  });
};
